
package com.trydofor.a9task.base.code.sysd;

import com.trydofor.a9task.base.code.help.Code;
import com.trydofor.a9task.base.code.help.CodeBuilder;
import com.trydofor.a9task.base.sys.anno.SystemData;

/**
 * @author : Shi Rongjiu (www.trydofor.com)
 * @date : 2012-12-28
 * @see :
 */

public abstract class UserStatus {

    public final static int    $   = GroupRoot.$USER_STATUS$;
    public final static String _   = "USER_STATUS$";
    @SystemData
    public final static Code   $_  = CodeBuilder.code(GroupRoot.$, $, _)
   	                                            .lang(Language.$EN_US, "status", "user status")
   	                                            .lang(Language.$ZH_CN, "状态", "用户状态")
                                                .done();
    
    public final static int    $NEED_LOGIN_INFO  = $ + 1;
    public final static String _NEED_LOGIN_INFO  = "USER_STATUS$NEED_LOGIN_INFO";
    @SystemData
    public final static Code   NEED_LOGIN_INFO   = CodeBuilder.code($, $NEED_LOGIN_INFO, _NEED_LOGIN_INFO)
   	                                               .lang(Language.$EN_US, "need login info", "need login info")
   	                                               .lang(Language.$ZH_CN, "须改密码", "必须修改密码")
                                                   .done();
    public final static int    $INACTIVE_STATUS  = $ + 2;
    public final static String _INACTIVE_STATUS  = "USER_STATUS$INACTIVE_STATUS";
    @SystemData
    public final static Code   INACTIVE_STATUS   = CodeBuilder.code($, $INACTIVE_STATUS, _INACTIVE_STATUS)
   	                                               .lang(Language.$EN_US, "inactive", "need to be activated")
   	                                               .lang(Language.$ZH_CN, "未激活", "状态需要激活")
                                                   .done();
    public final static int    $NEED_NEW_PASSWD  = $ + 3;
    public final static String _NEED_NEW_PASSWD  = "USER_STATUS$NEED_NEW_PASSWD";
    @SystemData
    public final static Code   NEED_NEW_PASSWD   = CodeBuilder.code($, $NEED_NEW_PASSWD, _NEED_NEW_PASSWD)
   	                                               .lang(Language.$EN_US, "need new password", "need to change password")
   	                                               .lang(Language.$ZH_CN, "须改密码", "必须修改密码")
                                                   .done();
    public final static int    $NOLOGIN_ACCOUNT  = $ + 4;
    public final static String _NOLOGIN_ACCOUNT  = "USER_STATUS$NOLOGIN_ACCOUNT";
    @SystemData
    public final static Code   NOLOGIN_ACCOUNT   = CodeBuilder.code($, $NOLOGIN_ACCOUNT, _NOLOGIN_ACCOUNT)
   	                                               .lang(Language.$EN_US, "nologin", "need Not to login")
   	                                               .lang(Language.$ZH_CN, "非登录", "不可登录账户")
                                                   .done();
    public final static int    $HEALTHY_ACCOUNT  = $ + 5;
    public final static String _HEALTHY_ACCOUNT  = "USER_STATUS$HEALTHY_ACCOUNT";
    @SystemData
    public final static Code   HEALTHY_ACCOUNT   = CodeBuilder.code($, $HEALTHY_ACCOUNT, _HEALTHY_ACCOUNT)
   	                                               .lang(Language.$EN_US, "healthy", "healthy account")
   	                                               .lang(Language.$ZH_CN, "健康", "健康账户")
                                                   .done();
    public final static int    $LEFTJOB_ACCOUNT  = $ + 6;
    public final static String _LEFTJOB_ACCOUNT  = "USER_STATUS$LEFTJOB_ACCOUNT";
    @SystemData
    public final static Code   LEFTJOB_ACCOUNT   = CodeBuilder.code($, $LEFTJOB_ACCOUNT, _LEFTJOB_ACCOUNT)
   	                                               .lang(Language.$EN_US, "leftjob", "left the job")
   	                                               .lang(Language.$ZH_CN, "已离职", "已离职的账户")
                                                   .done();
    public final static int    $STOPPED_ACCOUNT  = $ + 7;
    public final static String _STOPPED_ACCOUNT  = "USER_STATUS$STOPPED_ACCOUNT";
    @SystemData
    public final static Code   STOPPED_ACCOUNT   = CodeBuilder.code($, $STOPPED_ACCOUNT, _STOPPED_ACCOUNT)
   	                                               .lang(Language.$EN_US, "stopped", "stopped account")
   	                                               .lang(Language.$ZH_CN, "已停用", "已停止使用的账户")
                                                   .done();
    public final static int    $EXPIRED_ACCOUNT  = $ + 8;
    public final static String _EXPIRED_ACCOUNT  = "USER_STATUS$EXPIRED_ACCOUNT";
    @SystemData
    public final static Code   EXPIRED_ACCOUNT   = CodeBuilder.code($, $EXPIRED_ACCOUNT, _EXPIRED_ACCOUNT)
   	                                               .lang(Language.$EN_US, "expired", "expired account")
   	                                               .lang(Language.$ZH_CN, "已过期", "已过期的账户")
                                                   .done();
    public final static int    $MANY_BAD_PASSWD  = $ + 9;
    public final static String _MANY_BAD_PASSWD  = "USER_STATUS$MANY_BAD_PASSWD";
    @SystemData
    public final static Code   MANY_BAD_PASSWD   = CodeBuilder.code($, $MANY_BAD_PASSWD, _MANY_BAD_PASSWD)
   	                                               .lang(Language.$EN_US, "many bad password", "try too many bad password")
   	                                               .lang(Language.$ZH_CN, "多次错密码", "密码错误次数过多")
                                                   .done();
    public final static int    $ABNORMAL_ACCESS  = $ + 10;
    public final static String _ABNORMAL_ACCESS  = "USER_STATUS$ABNORMAL_ACCESS";
    @SystemData
    public final static Code   ABNORMAL_ACCESS   = CodeBuilder.code($, $ABNORMAL_ACCESS, _ABNORMAL_ACCESS)
   	                                               .lang(Language.$EN_US, "abnormal", "abnormal data access")
   	                                               .lang(Language.$ZH_CN, "异常访问", "异常数据访问")
                                                   .done();

    ///////////////////////
    /**
     * true if id is the system default data
     * @param id the code id
     * @return
     */
    public final static boolean in(int id){
        if($NEED_LOGIN_INFO == id) return true;
        if($INACTIVE_STATUS == id) return true;
        if($NEED_NEW_PASSWD == id) return true;
        if($NOLOGIN_ACCOUNT == id) return true;
        if($HEALTHY_ACCOUNT == id) return true;
        if($LEFTJOB_ACCOUNT == id) return true;
        if($STOPPED_ACCOUNT == id) return true;
        if($EXPIRED_ACCOUNT == id) return true;
        if($MANY_BAD_PASSWD == id) return true;
        if($ABNORMAL_ACCESS == id) return true;
        return false;
    }
    
    /**
     * get the code by id
     * @param id the code id
     * @return
     */
    public final static Code of(int id){
        if($NEED_LOGIN_INFO == id) return NEED_LOGIN_INFO;
        if($INACTIVE_STATUS == id) return INACTIVE_STATUS;
        if($NEED_NEW_PASSWD == id) return NEED_NEW_PASSWD;
        if($NOLOGIN_ACCOUNT == id) return NOLOGIN_ACCOUNT;
        if($HEALTHY_ACCOUNT == id) return HEALTHY_ACCOUNT;
        if($LEFTJOB_ACCOUNT == id) return LEFTJOB_ACCOUNT;
        if($STOPPED_ACCOUNT == id) return STOPPED_ACCOUNT;
        if($EXPIRED_ACCOUNT == id) return EXPIRED_ACCOUNT;
        if($MANY_BAD_PASSWD == id) return MANY_BAD_PASSWD;
        if($ABNORMAL_ACCESS == id) return ABNORMAL_ACCESS;
        return null;
    }
    
    /**
     * get the code by key
     * @param id the code key
     * @return
     */
    public final static Code of(String key){
        if(key == null) return null;
        if(_NEED_LOGIN_INFO.equals(key)) return NEED_LOGIN_INFO;
        if(_INACTIVE_STATUS.equals(key)) return INACTIVE_STATUS;
        if(_NEED_NEW_PASSWD.equals(key)) return NEED_NEW_PASSWD;
        if(_NOLOGIN_ACCOUNT.equals(key)) return NOLOGIN_ACCOUNT;
        if(_HEALTHY_ACCOUNT.equals(key)) return HEALTHY_ACCOUNT;
        if(_LEFTJOB_ACCOUNT.equals(key)) return LEFTJOB_ACCOUNT;
        if(_STOPPED_ACCOUNT.equals(key)) return STOPPED_ACCOUNT;
        if(_EXPIRED_ACCOUNT.equals(key)) return EXPIRED_ACCOUNT;
        if(_MANY_BAD_PASSWD.equals(key)) return MANY_BAD_PASSWD;
        if(_ABNORMAL_ACCESS.equals(key)) return ABNORMAL_ACCESS;
        return null;
    }
}
